import ajax, { ListResult, toOptions } from '../ajax';
import { computed, ref } from 'vue';


export function getList(data:any) {
  return ajax.post<ListResult>('/Problems/ProblemCollections/Query', data);
}

export function updateEntity(data:any) {
  if(data.collectionId) {
    return ajax.put<any>('/Problems/ProblemCollections', data);
  } else {
    return ajax.post<any>('/Problems/ProblemCollections', data);
  }
}

export function deleteEntity(id:number) {
  let deleteCommand = {"id": id};
  return ajax.put<any>('/Problems/ProblemCollections/Actions/Delete', deleteCommand);
}


export function getProblemList(collectionId: number) {
  return ajax.get<ListResult>(`/Problems/ProblemCollections/${collectionId}/Problems`);
}

export function getProblemCollection(id: number) {
  return ajax.get<any>(`/Problems/ProblemCollections/${id}`);
}
